import React from "react";
import { createBrowserRouter,Navigate} from "react-router-dom";
import Home from "../pages/Home/index"
import Main from '../pages/main'
import PageOne from '../pages/Other/pageone'
import PageTwo from '../pages/Other/pagetwo'
import Mall from "../pages/Mall/index"
import User from "../pages/User/index";
import Login from "../pages/Login/index"


const routes  = [
    {
        path:"/",
        Component:Main,
        children:[
            // 路由重定向，当访问/时，重定向到home
            {
                path:'/',
                element:<Navigate to="/home"/>


            },
            {
                path:"home",
                element:<Home/>,
                
            },
            {
                path:"user",
                element:<User/>
            },
            {
                path:"mail",
                element:<Mall/>
            },
            {
                path:"other",
                children:[
                    {
                        path:"pageone",
                        element:<PageOne/>
                    },
                    {
                        path:"pagetwo",
                        element:<PageTwo/>
                    }
                ]
            }
        ]
    },
    {
        path:'/login',
        Component:Login

    }

]
export default createBrowserRouter(routes)